<!DOCTYPE html>
<html>
<head>
	<title><%= title%></title>
	<meta charset="utf-8">
	<link rel="stylesheet" type="text/css" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="../styles/main.css">
	<script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
	<script type="text/javascript" src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../bower_components/kindeditor/kindeditor-min.js"></script>
	<script type="text/javascript" src="../bower_components/kindeditor/lang/zh-CN.js"></script>
	<script type="text/javascript" src="../bower_components/upload-jquery/jquery.upload.js"></script>
	<script type="text/javascript" src="../scripts/main.js"></script>
</head>
<style type="text/css">
	.form-group{
		overflow: hidden;
	}
</style>
<body>
	<div class="container">
		<form action="/admin/editArticle" method="post" >
			<div class="rows">
				<div class="col-md-offset-2 col-md-9">
					<div class="page-header">
						编辑文章
					</div>
					<input type="hidden" name="id" value="<%=articles.id%>">
					<div class="form-group">
					    <label>文章标题</label>
					    <div class="rows">
						    <div class="col-md-11">
						    	<input type="text" class="form-control" value="<%=articles.title%>" placeholder="请输入文章标题" name="title">
						    </div>
						    <div class="col-md-1" style="height: 34px;line-height: 34px;color: red;">
						    	<span>*</span>
						    </div>
						</div>
					</div>
					<div class="form-group">
					    <label>图片</label>
					    <div>
					    	<div class="col-md-9">
					    	<div class="bk" style="background:url(/<%=articles.img%>) no-repeat center center ;background-size:100% auto;">
					    	</div>
					    	<input type="hidden" id="img" name="img" class="form-control" value="<%=articles.img%>">
						    </div>
						    <div  class="col-md-2">
						    	<input type="button" class="btn btn-info" onclick="doUpload()" value="点击上传">
						    </div>
						    <div class="col-md-1" style="height: 34px;line-height: 34px;color: red;">
						    	<span>*</span>
						    </div>
					    </div>
					</div>
					<div class="form-group">
					     <label style="display: block;">分类：</label>
					     <div class="col-md-11">
						    <select name="cata_id" class="form-control">
						    <%for(var i=0;i<catalogs.length;i++){%>
						    	<option <% if (articles.cata_id==catalogs[i].id){ %> selected="selected" <%}%> value="<%=catalogs[i].id %>"><%=catalogs[i].name %></option>
						    <%}%>
						    </select>
						</div>
						<div class="col-md-1" style="height: 34px;line-height: 34px;color: red;">
					    	<span>*</span>
					    </div>
					</div>
					<div class="form-group">
					    <label>文章内容</label>
					    <textarea type="text" class="form-control" rows="10"  placeholder="请输入文章内容" name="content"><%=articles.content%></textarea> 
					</div>
					
					<button type="submit" class="btn btn-success">提交</button>
					<a class="btn btn-info" href="/admin">返回列表</a>
				</div>
			</div>
		</form>

		<!-- <div class="modal fade" id="myModal" tabindex="-1">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<h4 class="modal-title" id="myModalLabel">上传图片</h4>
					</div>
					<div class="modal-body">
						<form method="post" action="/admin/uploadfile" enctype="multipart/form-data" name="fileForm" target="fileUpload">
							<input type="file" class="fileInput  article_sub" name="fileInput">
						<iframe name="fileUpload" class="hidden"></iframe>
						</div>
						<div class="modal-footer">
							<input type="submit" class="btn btn-primary" value="提交" />
						</div>
					</form>
				</div>
			</div>
		</div> -->


		
	</div>
	<script>
        var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="content"]', {
				allowFileManager : true
			});
		})
		// function aaa(a){
		// 	$('#img').val(a)
		// 	$('#myModal').modal('hide')
		// }
		function doUpload() {
			// 上传方法
			$.upload({
					// 上传地址
					url: '/admin/uploadfile', 
					// 文件域名字
					fileName: 'fileInput', 
					// 其他表单数据
					params: {},
					// 上传完成后, 返回json, text
					dataType: 'text',
					// 上传之前回调,return true表示可继续上传
					onSend: function() {
							return true;
					},
					// 上传之后回调
					onComplate: function(data) {
						$('#img').val(data)
						// $('#img_prv').attr('src',"/"+data)
						// $('#img_prv').css('display','inline')
						$(".bk").attr("style","background:url(/"+data+") no-repeat center center ;background-size:100% auto;")
					}
			});
		}
</script>
</body>
</html>